#ifndef _TREENODE_H_INCLUDED_
#define _TREENODE_H_INCLUDED_

#include "Allocator.h"
#include <GlobalData.h>

class FTBitmapChar;

class TreeNode
{
private:
	int 						x;
	int 						y;
	int 						width;
	int 						height;
	TreeNode					*leaf1;
	TreeNode					*leaf2;
	static Allocator<TreeNode> 	allocator;

private:
	void createBranches(FTBitmapChar* bitmapChar);
	bool fits(FTBitmapChar* bitmapChar);

public:
	TreeNode();
	TreeNode(int x, int y, int width, int height);
	~TreeNode();

	void set(int x, int y, int width, int height);
	bool add(FTBitmapChar* bitmapChar);

	bool isEmpty() const {
		return leaf1 == NULL && leaf2 == NULL;
	}
	static Allocator<TreeNode>& getAllocator() {
		return allocator;
	}
};

#endif // _TREENODE_H_INCLUDED_
